/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import entity.Gejala;
import entity.KelolaGejala;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Aditya-Z
 */
public class LogikaGejala {
    
    HttpServletRequest request;

    public LogikaGejala(HttpServletRequest request) {
        this.request = request;
    }

    public String daftar() {
        HttpSession session = request.getSession();
        RequestDispatcher dis = null;
        Gejala gejala = new Gejala();
        KelolaGejala ka = new KelolaGejala();

        String  namkit = request.getParameter("Nama_penyakit");
        String tingkit = request.getParameter("tingkit");
        String ketgejala = request.getParameter("ketgejala");
        
       
            gejala.setNamaPenyakit(namkit);
            gejala.setTingkatPenyakit(tingkit);
            gejala.setGejala(ketgejala);
            
           ka.createGejala(gejala);
           return "listGejala.jsp";
           

        
    
    }

    public String search(){
        Gejala gejala = new Gejala();
        KelolaGejala kg = new KelolaGejala();
        String panas = request.getParameter("panas");
        String mual = request.getParameter("mual");
        String pusing = request.getParameter("pusing");
        String mencret = request.getParameter("mencret");
        String muntah = request.getParameter("muntah");
        String uluhati = request.getParameter("ulu_hati");
        String gjl = "";
        if(panas!=null) gjl += "panas,";
        if(mual!=null) gjl += "mual,";
        if(pusing!=null) gjl += "pusing,";
        if(mencret!=null) gjl += "mencret,";
        if(muntah!=null) gjl += "muntah,";
        if(uluhati!=null) gjl += "uluhati,";
        List hasil = kg.search(gjl);
        request.setAttribute("penyakit", hasil);
        return "search.jsp";
    }

    public String search2(){
        Gejala gejala = new Gejala();
        KelolaGejala kg = new KelolaGejala();
        String gjl = request.getParameter("Search");
        List hasil = kg.search(gjl);
        request.setAttribute("penyakit", hasil);
        return "search.jsp";
    }
    }
    

    